<?php

namespace app\admin\controller;

use app\common\controller\Backend;
use think\Controller;
use think\Request;

class DeliveryKeyUserRelation extends Backend
{
    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\common\model\DeliveryKeyUserRelation();;
    }
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index()
    {
        if($this->request->isAjax()) {
            [$where, $sort, $order, $offset, $limit] = $this->buildparams();
            $list = $this->model->with(['userShow', 'delivery_key' => function($query) {
                $query->withField('id,key');
            }])->where($where)
            ->order($sort, $order)
            ->paginate($limit);
            $result = ['total' => $list->total(), 'rows' => $list->items()];
            return json($result);
        }
        return $this->fetch();
    }
}
